<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:fragment xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">
	<a4j:outputPanel id="agenteChangePanelId" ajaxRendered="true">
		<rich:panel styleClass="rich-stglpanel-body">
			<f:facet name="header">#{messages['label.agente.cadastro']}</f:facet>
			<s:decorate template="/layout/edit.xhtml">
				<ui:define name="label">#{messages['label.matricula']}</ui:define>
				<h:inputText 
					value="#{agenteAction.entity.matricula}"
					label="#{messages['label.matricula']}" 
					required="true" 
					size="50"
					onkeyup="toUpperCase(this,'')">
				</h:inputText>
			</s:decorate>
			<s:decorate template="/layout/edit.xhtml">
				<ui:define name="label">#{messages['label.nome']}</ui:define>
				<h:inputText 
					value="#{agenteAction.entity.nome}"
					label="#{messages['label.nome']}" 
					required="true" 
					size="50"
					onkeyup="toUpperCase(this,'')">
				</h:inputText>
			</s:decorate>
			<s:decorate template="/layout/edit.xhtml">
				<ui:define name="label">#{messages['label.sobrenome']}</ui:define>
				<h:inputText 
					value="#{agenteAction.entity.sobreNome}"
					label="#{messages['label.sobrenome']}" 
					required="true" 
					size="50"
					onkeyup="toUpperCase(this,'')">
				</h:inputText>
			</s:decorate>
			<s:decorate template="/layout/edit.xhtml">
				<ui:define name="label">#{messages['label.tipopessoa']}</ui:define>
				<h:inputText 
					value="#{agenteAction.entity.tipoPessoa}"
					label="#{messages['label.tipopessoa']}" 
					required="true" 
					size="50"
					onkeyup="toUpperCase(this,'')">
				</h:inputText>
			</s:decorate>
			<s:decorate template="/layout/edit.xhtml">
				<ui:define name="label">#{messages['label.contatos']}</ui:define>
				<h:inputText 
					value="#{agenteAction.entity.contatos}"
					label="#{messages['label.contatos']}" 
					required="true" 
					size="50"
					onkeyup="toUpperCase(this,'')">
				</h:inputText>
			</s:decorate>	
			<s:decorate template="/layout/edit.xhtml">
				<ui:define name="label">#{messages['label.mae']}</ui:define>
				<h:inputText 
					value="#{agenteAction.entity.mae}"
					label="#{messages['label.mae']}" 
					required="true" 
					size="50"
					onkeyup="toUpperCase(this,'')">
				</h:inputText>
			</s:decorate>
			<s:decorate template="/layout/edit.xhtml">
				<ui:define name="label">#{messages['label.pai']}</ui:define>
				<h:inputText 
					value="#{agenteAction.entity.pai}"
					label="#{messages['label.pai']}" 
					required="true" 
					size="50"
					onkeyup="toUpperCase(this,'')">
				</h:inputText>
			</s:decorate>	
			<!-- RENDERIZA ENDEREÇO -->	
			<s:decorate template="/layout/edit.xhtml">									
	       			<a4j:commandButton ajaxSingle="true" immediate="true"
						value="#{messages['label.exibe.endereco']}"
						rendered="#{!agenteAction.renderizaEndereco}"
						action="#{agenteAction.alteraRenderizacaoEndereco}"/>

	       			<a4j:commandButton ajaxSingle="true" immediate="true"
						value="#{messages['label.omite.endereco']}"
						rendered="#{agenteAction.renderizaEndereco}"
						action="#{agenteAction.alteraRenderizacaoEndereco}"/>

			<h:panelGrid rendered="#{agenteAction.renderizaEndereco}" >
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.endereco.cep']}</ui:define>
					<h:inputText 
						value="#{agenteAction.entity.endereco.cep}"
						label="#{messages['label.endereco.cep']}" 
						required="true" 
						size="10"
						maxlength="9"
						onkeyup="toUpperCase(this,'')">
					</h:inputText>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.endereco.posicaoGPS']}</ui:define>
					<h:inputText 
						value="#{agenteAction.entity.endereco.posicaoGPS}"
						label="#{messages['label.endereco.posicaoGPS']}" 
						required="true" 
						size="20"
						maxlength="20"
						onkeyup="toUpperCase(this,'')">
					</h:inputText>
				</s:decorate>				
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.endereco.estado']}</ui:define>
					<h:selectOneMenu
						value="#{agenteAction.entity.endereco.estado}" 
						label="#{messages['label.endereco.estado']}" 
						required="false"
						style="width:300px;">
						<f:converter converterId="br.com.o2solutions.siso.webapp.converter.EntidadeBaseConverter"/>
						<s:selectItems
							value="#{enderecoAction.resultList}"
							var="_pais"
							label="#{_estado.ddd}"
							noSelectionLabel="#{messages['label.estado']}"/>
					</h:selectOneMenu>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.endereco.cidade']}</ui:define>
					<h:selectOneMenu
						value="#{agenteAction.entity.endereco.cidade}" 
						label="#{messages['label.endereco.cidade']}" 
						required="false"
						style="width:300px;">
						<f:converter converterId="br.com.o2solutions.siso.webapp.converter.EntidadeBaseConverter"/>
						<s:selectItems
							value="#{enderecoAction.resultList}"
							var="_cidade"
							label="#{_cidade}"
							noSelectionLabel="#{messages['label.cidade']}"/>
					</h:selectOneMenu>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.endereco.bairro']}</ui:define>
					<h:selectOneMenu
						value="#{agenteAction.entity.endereco.bairro}" 
						label="#{messages['label.endereco.bairro']}" 
						required="false"
						style="width:300px;">
						<f:converter converterId="br.com.o2solutions.siso.webapp.converter.EntidadeBaseConverter"/>
						<s:selectItems
							value="#{enderecoAction.resultList}"
							var="_bairro"
							label="#{_bairro}"
							noSelectionLabel="#{messages['label.bairro']}"/>
					</h:selectOneMenu>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.endereco.logradouro']}</ui:define>
					<h:selectOneMenu
						value="#{agenteAction.entity.endereco.logradouro}" 
						label="#{messages['label.endereco.logradouro']}" 
						required="false"
						style="width:300px;">
						<f:converter converterId="br.com.o2solutions.siso.webapp.converter.EntidadeBaseConverter"/>
						<s:selectItems
							value="#{enderecoAction.resultList}"
							var="_logradouro"
							label="#{_logradouro.numero}"
							noSelectionLabel="#{messages['label.logradouro']}"/>
					</h:selectOneMenu>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.endereco.logradouro.numero']}</ui:define>
					<h:inputText 
						value="#{agenteAction.entity.endereco.logradouro.numero}"
						label="#{messages['label.logradouro.numero']}" 
						required="true" 
						size="20"
						onkeyup="toUpperCase(this,'')">
					</h:inputText>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.endereco.logradouro.complemento']}</ui:define>
					<h:inputText 
						value="#{agenteAction.entity.endereco.logradouro.complemento}"
						label="#{messages['label.logradouro.complemento']}" 
						required="true" 
						size="20"
						onkeyup="toUpperCase(this,'')">
					</h:inputText>
				</s:decorate>																				
		  </h:panelGrid>
		  </s:decorate>
		  <!-- RENDERIZA CONTATO -->
		<s:decorate template="/layout/edit.xhtml">  
	     	<a4j:commandButton ajaxSingle="true" immediate="true"
				value="#{messages['label.exibe.contato']}"
				rendered="#{!agenteAction.renderizaContato}"
				action="#{agenteAction.alteraRenderizaContato}"/>
	
	     	<a4j:commandButton ajaxSingle="true" immediate="true"
				value="#{messages['label.omite.contato']}"
				rendered="#{agenteAction.renderizaContato}"
				action="#{agenteAction.alteraRenderizaContato}"/>
	
			<h:panelGrid rendered="#{agenteAction.renderizaContato}" >
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.contato.tipo']}</ui:define>
						<h:inputText 
							value="#{agenteAction.entity.contato.tipoContato}"
							label="#{messages['label.contato.tipo']}" 
							required="true" 
							size="50"
							onkeyup="toUpperCase(this,'')">
						</h:inputText>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.contato.valor']}</ui:define>
						<h:inputText 
							value="#{agenteAction.entity.contato.valor}"
							label="#{messages['label.contato.valor']}" 
							required="true" 
							size="50"
							onkeyup="toUpperCase(this,'')">
						</h:inputText>
				</s:decorate>
			</h:panelGrid>
		</s:decorate>

		</rich:panel>
		<s:decorate template="/layout/button.xhtml">
			<ui:param name="action" value="#{agenteAction}" />

			<ui:param name="renderedSave"
				value="#{agenteAction.entity.id==null}" />
			<ui:param name="limitToListOnSave" value="true" />
			<ui:param name="reRenderOnSave"
				value="agenteChangePanelId,agenteOutputId,agenteMensagemPanelId" />

			<ui:param name="renderedUpdate"
				value="#{agenteAction.entity.id!=null}" />
			<ui:param name="limitToListOnUpdate" value="true" />
			<ui:param name="reRenderOnUpdate"
				value="agenteChangePanelId,agenteOutputId,agenteMensagemPanelId" />
				
			<ui:param name="renderedRemove"
				value="#{agenteAction.entity.id!=null}" />
			<ui:param name="limitToListOnRemove" value="true" />
			<ui:param name="reRenderOnRemove"
				value="agenteChangePanelId,agenteOutputId,agenteMensagemPanelId" />
				
		</s:decorate>
	
	</a4j:outputPanel>
				  
		
</ui:fragment>
